#ifndef RENDERER_H
#define RENDERER_H
//--------------------------------------------------------------------------------
#include "Defines.h"
#include <d3dx9.h>
#include <d3d9.h>
#include "Structs.h"
#include "Texture.h"
//--------------------------------------------------------------------------------
#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")
//--------------------------------------------------------------------------------
namespace ns
{
	template<class PixelFormatClass,unsigned int FVF>
	class VertexBuffer;

	class Renderer
	{

	public:
		Renderer(HWND hWnd);
		~Renderer();
		
		HWND m_hWnd;

		D3DXVECTOR3 m_kViewerPos;
		D3DXVECTOR3 m_kViewerUp;

		void StartFrame();
		void EndFrame();
		bool InitDX(HWND hWnd);
		void Draw(ColorVertex* vertex, PrimitiveType primitive ,size_t vertexCount);
		void Draw(TextureVertex* textureVertex,PrimitiveType primitive, size_t vertexCount);
		//DANI
		//	Metodos de Textura
		void UnbindTexture ();
		bool BindTexture (Texture::Ptr rkTexture);
		bool LoadTexture (const char* pszFilename, Texture::Ptr rkTexture);
		//-----

		//para dibujar triangulo con renderer usando el tutorial
		//LPDIRECT3DVERTEXBUFFER9 g_pVB;
		//HRESULT IniBufferVert(void);		
		//-------------------------------------------------------
		void Translate(float fX,float fY, float fZ);
		void Scale(float fW, float fH);
		void RotateZ(float fRot);
		void LoadIdentity();
		void setMatrixMode(MatrixMode eMode);

	private:
		IDirect3DDevice9* m_pDevice;
		LPDIRECT3D9	m_pD3D;	
		VertexBuffer<ColorVertex,COLOR_VERTEX>* m_pVB;
		VertexBuffer<TextureVertex,TEXTURE_VERTEX>* m_pTextureVB;
		MatrixMode mCurrentMatrixMode;

		//dani
		map <string, IDirect3DTexture9*> m_kTextureMap;
		typedef map<string, IDirect3DTexture9*>::iterator TextureIterator;
		//--

	};
}
//--------------------------------------------------------------------------------
#endif